<?php
session_start();

if(isset($_SESSION['auth']))
{
    if(!$_SESSION['auth']==1)
    {
        header("Location: index.php");
    }
}
else
{
    header("Location: index.php");
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="style.css" rel=stylesheet type="text/css"></link>
        <title>
            Voting Title
        </title>
    </head>
    <body>
        <div id="main_wrapper">
            <div id="top_header_wrapper">
                <div id="title_top">
                     Voting
                </div>
                <div id="login_wrapper">
                    <label>Welcome,</label> <a href="javascript:void(0)" id="username"><?php echo $_SESSION['username'] ?></a>
                    <a href="Process/Process.php?task=logout" id="logout">logout</a>
                </div>
            </div>
            <div id="body_wrapper">
                <?php
                require_once 'Process/drawfield.php';
                $query="SELECT * FROM pollingfield;";
                $result=  mysql_query($query);
                $userid=$_SESSION['userid'];
                while($rows=  mysql_fetch_array($result))
                {
                    $output=drawpoll($rows['id'], $userid);
                    echo $output;
                }
                ?>
            </div>
        </div>
    </body>
</html>
